package com.sander.guardmanagement.ui.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sander.guardmanagement.R;
import com.sander.guardmanagement.response.ResponseHomeGetBuildingData;
import com.sander.guardmanagement.ui.model.DistrictBoxModel;
import com.sander.guardmanagement.ui.model.DistrictItem;

import java.util.List;

/**
 * Created by sander on 2017/4/22.
 */

public class DistrictUnitAdapter extends BaseAdapter {
    private Context context;

    private LayoutInflater inflater;

    public List<ResponseHomeGetBuildingData> unitList;

    public DistrictUnitAdapter(Context context, List<ResponseHomeGetBuildingData> list){
        this.context = context;
        inflater = LayoutInflater.from(this.context);
        this.unitList = list;
    }
    @Override
    public int getCount() {
        return this.unitList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        DistrictItem item = null;
        if (convertView == null){
            convertView = this.inflater.inflate(R.layout.districtitem,parent,false);
            item = new DistrictItem();
            item.setTextView((TextView) convertView.findViewById(R.id.distrivtText));
            convertView.setTag(item);
        }else{
            item = (DistrictItem )convertView.getTag();
        }
        ResponseHomeGetBuildingData unitString = unitList.get(position);
        item.getTextView().setText(unitString.getBuilding_name());
        return convertView;
    }
}
